const db = uniCloud.database()
exports.main = async (event, context) => {
  const { topicId } = event
  const userId = context.APPID || context.UNID // 根据实际用户体系调整
  
  const record = await db.collection('topics_records')
    .where({
      topicId,
      userId
    })
    .get()

  return {
    votedType: record.data[0]?.type || null
  }
}